﻿<%@ Page Language="C#" MasterPageFile="~/Manager.master" AutoEventWireup="true" CodeFile="ViewOrderDetail.aspx.cs" Inherits="Manager_OrderDetail_ViewOrderDetail" Title="Untitled Page" %>
<%@ Register TagPrefix="ComponentArt" Namespace="ComponentArt.Web.UI" Assembly="ComponentArt.Web.UI" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

    <script type="text/javascript" language="javascript">
      function Picker1_onSelectionChanged(sender, eventArgs)
      {
        cldStart.SetSelectedDate(Picker1.GetSelectedDate());   
        cldStart.Show();
      }
      function cldStart_onSelectionChanged(sender, eventArgs)
      {
      
            var fromDate = cldStart.GetSelectedDate();
            var toDate = cldEnd.GetSelectedDate();
            Picker1.SetSelectedDate(fromDate);            
           /* if(fromDate > toDate)
            {
              Picker2.SetSelectedDate(fromDate);
              cldEnd.SetSelectedDate(fromDate);
            }  */             
      }
      
      function Picker2_onSelectionChanged(sender, eventArgs)
      {
        cldEnd.SetSelectedDate(Picker2.GetSelectedDate());
        cldEnd.Show();
      }
      function cldEnd_onSelectionChanged(sender, eventArgs)
      {         
            var fromDate = cldStart.GetSelectedDate();
            var toDate = cldEnd.GetSelectedDate();
            Picker2.SetSelectedDate(toDate);            
           /* if(fromDate > toDate)
            {
              Picker1.SetSelectedDate(toDate);
              cldStart.SetSelectedDate(toDate);
            }         */           
      }
    //]]>
    </script>

    <table border="0" cellpadding="0" cellspacing="0" style="width: 100%">
        <tr>
            <td nowrap="nowrap" style="height: 3px">
                <table border="1" cellpadding="2" cellspacing="0" style="width: 100%; border-collapse: collapse"
                    bordercolor="#407db3" bgcolor="#f7ffe4">
                    <tr>
                        <td align="center" nowrap="nowrap">
                            <asp:Button ID="btnSearch" runat="server" CssClass="cssButton" Text="Tìm kiếm" Width="81px"
                                OnClick="btnSearch_Click" /></td>
                        <td nowrap="nowrap" class="td_Title">
                            <asp:Label ID="Label5" runat="server" Text="Ngày đặt hàng:"></asp:Label>
                            &nbsp;
                        </td>
                        <td colspan="4" nowrap="nowrap">
                            <table border="0" cellpadding="0" cellspacing="0">
                                <tbody>
                                    <tr>
                                        <td>
                                        </td>
                                        <td align="center">
                                            <ComponentArt:Calendar ID="Picker1" runat="server" ControlType="Picker" PickerCssClass="picker"
                                                PickerCustomFormat="dd/MM/yyyy" PickerFormat="Custom" ClientSideOnSelectionChanged="Picker1_onSelectionChanged">
                                            </ComponentArt:Calendar>
                                        </td>
                                        <td>
                                            &nbsp;
                                            <img id="calendar_start_button" alt="" class="calendar_button" height="22" onclick="cldStart .SetSelectedDate(Picker1.GetSelectedDate());cldStart .Show();"
                                                src="../../Images/Icon/btn_calendar.gif" width="25" />
                                        </td>
                                        <td align="center" style="width: 2px">
                                            &nbsp;~&nbsp;</td>
                                        <td align="center">
                                            <ComponentArt:Calendar ID="Picker2" runat="server" ControlType="Picker" PickerCssClass="picker"
                                                PickerCustomFormat="dd/MM/yyyy" PickerFormat="Custom" ClientSideOnSelectionChanged="Picker2_onSelectionChanged">
                                            </ComponentArt:Calendar>
                                        </td>
                                        <td>
                                            &nbsp;
                                            <img id="calendar_end_button" alt="" class="calendar_button" height="22" onclick="cldEnd.SetSelectedDate(Picker2.GetSelectedDate());cldEnd.Show();"
                                                src="../../Images/Icon/btn_calendar.gif" width="25" />
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                        </td>
                    </tr>
                    <tr>
                        <td id="Td1" runat="server" align="center" nowrap="nowrap">
                            <input id="Button1" class="cssButton" type="button" runat="server" value="Quay lại"
                                onclick="javascript:history.go(-1)" style="width: 81px" /></td>
                        <td nowrap="nowrap" class="td_Title">
                            <asp:Label ID="Label1" runat="server" Text="Đơn đặt hàng:"></asp:Label></td>
                        <td nowrap="nowrap">
                            <asp:TextBox ID="txtDDH" runat="server" CssClass="txt_Product" Width="120px"></asp:TextBox></td>
                        <td nowrap="nowrap" class="td_Title">
                            <asp:Label ID="Label4" runat="server" Text="Trạng thái:"></asp:Label></td>
                        <td nowrap="nowrap">
                            <asp:DropDownList ID="ddlState" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddlState_SelectedIndexChanged">
                                <asp:ListItem Value="N">Chờ xác nhận</asp:ListItem>
                                <asp:ListItem Value="Y">Đ&#227; xác nhận</asp:ListItem>
                                <asp:ListItem Value="E">Đã giao hàng</asp:ListItem>
                                <asp:ListItem Value="C">Hủy bỏ</asp:ListItem>
                            </asp:DropDownList>&nbsp;
                        </td>
                        <td nowrap="nowrap" align="center">
                            <asp:ImageButton ID="imgExportExcel" runat="server" ImageUrl="../../Images/Icon/icon_excel.gif"
                                ToolTip="Export to Excel" OnClick="imgExportExcel_Click" Visible="false" /></td>
                    </tr>
                </table>
            </td>
        </tr>
        <tr>
            <td align="right" style="height: 2px">
              </td>
        </tr>
        <tr>
            <td colspan="1" nowrap="nowrap">
                <asp:GridView ID="grvMaster" runat="server" AutoGenerateColumns="False" CellPadding="2"
                    BorderWidth="1px" Width="100%" OnRowDataBound="grvMaster_RowDataBound" DataKeyNames="OrderID"
                    BorderColor="#407db3">
                    <Columns>
                        <asp:TemplateField HeaderStyle-Width="1%">
                            <HeaderTemplate>
                            </HeaderTemplate>
                            <ItemTemplate>
                            </ItemTemplate>
                            <ItemStyle CssClass="cssBorderGrv" Width="1%" HorizontalAlign="Center" />
                            <HeaderStyle CssClass="cssBorderGrv" Width="1%" />
                        </asp:TemplateField>
                        <asp:TemplateField>
                            <HeaderTemplate>
                                T&#234;n Kh&#225;ch H&#224;ng</HeaderTemplate>
                            <ItemTemplate>
                                <asp:Label ID="hplHoten" runat="server"></asp:Label>
                            </ItemTemplate>
                            <ItemStyle CssClass="MergeCellRow" BackColor="#b5f0fb" />
                            <HeaderStyle CssClass="cssBorderGrv" Width="15%" />
                        </asp:TemplateField>
                        <asp:BoundField DataField="PDName" HeaderText="Tên sản phẩm">
                            <ItemStyle CssClass="cssBorderGrv" />
                            <HeaderStyle CssClass="cssBorderGrv" Width="25%" />
                        </asp:BoundField>
                        <asp:BoundField DataField="Quantity" HeaderText="Số lượng">
                            <ItemStyle HorizontalAlign="Right" CssClass="cssBorderGrv" />
                            <HeaderStyle CssClass="cssBorderGrv" Width="3%" Wrap="false" />
                        </asp:BoundField>
                        <asp:BoundField DataField="Price" HeaderText="Đơn gi&#225;" DataFormatString="{0:###,###,##0}">
                            <ItemStyle HorizontalAlign="Right" CssClass="cssBorderGrv" Wrap="false" />
                            <HeaderStyle CssClass="cssBorderGrv" Width="3%" />
                        </asp:BoundField>
                        <asp:BoundField DataField="Total" HeaderText="Th&#224;nh tiền" DataFormatString="{0:###,###,##0}">
                            <ItemStyle HorizontalAlign="Right" CssClass="cssBorderGrv" Wrap="false" />
                            <HeaderStyle CssClass="cssBorderGrv" Wrap="False" Width="5%" />
                        </asp:BoundField>
                        <asp:TemplateField HeaderStyle-Width="1%">
                            <HeaderTemplate>
                                S/L Kho
                            </HeaderTemplate>
                            <ItemTemplate>
                            </ItemTemplate>
                            <ItemStyle CssClass="cssBorderGrv" Width="1%" HorizontalAlign="Center" />
                            <HeaderStyle CssClass="cssBorderGrv" Width="1%" />
                        </asp:TemplateField>
                        <asp:TemplateField>
                            <HeaderTemplate>
                            </HeaderTemplate>
                            <ItemTemplate>
                                <img id="imgSave" runat="server" />
                            </ItemTemplate>
                            <ItemStyle CssClass="cssBorderGrv" Width="3%" HorizontalAlign="Center" />
                            <HeaderStyle CssClass="cssBorderGrv" />
                        </asp:TemplateField>
                    </Columns>
                    <RowStyle CssClass="gvRowStyle" Height="10px" />
                    <HeaderStyle CssClass="cssHeader" Height="20px" HorizontalAlign="Center" Wrap="False" />
                    <AlternatingRowStyle CssClass="gvAlternatingRowStyle" Height="10px" />
                    <FooterStyle Font-Bold="True" />
                    <EmptyDataTemplate>
                        <asp:Label ID="lblEmpty" runat="server" Text="Chưa có đơn đặt hàng"></asp:Label>
                    </EmptyDataTemplate>
                    <EmptyDataRowStyle Font-Size="13px" ForeColor="#ff0000" Font-Names="Tahoma" />
                </asp:GridView>
            </td>
        </tr>
        <tr>
            <td nowrap="nowrap">
                &nbsp;</td>
        </tr>
    </table>
    <ComponentArt:Calendar ID="cldStart" runat="server" AllowMonthSelection="False" AllowMultipleSelection="False"
        AllowWeekSelection="False" CalendarCssClass="calendar" CalendarTitleCssClass="title"
        ControlType="Calendar" DayCssClass="day" DayHeaderCssClass="dayheader" DayHoverCssClass="dayhover"
        DayNameFormat="Full" MonthCssClass="month" NextImageUrl="../../Images/Icon/cal_nextMonth.gif"
        NextPrevCssClass="nextprev" OtherMonthDayCssClass="othermonthday" PopUp="Custom"
        PopUpExpandControlId="calendar_start_button" PrevImageUrl="../../Images/Icon/cal_prevMonth.gif"
        SelectedDate="2008-11-17" SelectedDayCssClass="selectedday" SelectMonthCssClass="selector"
        SelectMonthText="¤" SelectWeekCssClass="selector" SelectWeekText="»" SwapDuration="300"
        SwapSlide="Linear" VisibleDate="2008-11-17" ClientSideOnSelectionChanged="cldStart_onSelectionChanged">
    </ComponentArt:Calendar>
    <ComponentArt:Calendar ID="cldEnd" runat="server" AllowMonthSelection="False" AllowMultipleSelection="False"
        AllowWeekSelection="False" CalendarCssClass="calendar" CalendarTitleCssClass="title"
        ControlType="Calendar" DayCssClass="day" DayHeaderCssClass="dayheader" DayHoverCssClass="dayhover"
        DayNameFormat="Full" MonthCssClass="month" NextImageUrl="../../Images/Icon/cal_nextMonth.gif"
        NextPrevCssClass="nextprev" OtherMonthDayCssClass="othermonthday" PopUp="Custom"
        PopUpExpandControlId="calendar_end_button" PrevImageUrl="../../Images/Icon/cal_prevMonth.gif"
        SelectedDate="2008-11-17" SelectedDayCssClass="selectedday" SelectMonthCssClass="selector"
        SelectMonthText="¤" SelectWeekCssClass="selector" SelectWeekText="»" SwapDuration="300"
        SwapSlide="Linear" VisibleDate="2008-11-17" ClientSideOnSelectionChanged="cldEnd_onSelectionChanged">
    </ComponentArt:Calendar>
    <input type="hidden" id="hPrint" runat="server" value="0" />

    <script language="javascript" type="text/javascript">
    function fnCheckAll(obj)
    {
        var grvMaster=document.getElementById("<%= grvMaster.ClientID %>");
        var flag=false;
        if(obj.checked==true)
        {   
            flag=true;        
        }
         for(var i=0;i<grvMaster.rows.length;i++)
         {           
             try
             {
                grvMaster.rows[i].cells[0].children[0].checked=flag;
               }catch(e) {};               
          }  
    }
    
    function ProcessOrder(sState)
    {
        var sOrderID='<%=Request["sOrderID"]%>'
        Manager_OrderDetail_OrderDetailOK.AjaxUpdateOrderState(sState,sOrderID,CallBackClient)
    }
    function CallBackClient(res)
    {
        if(res!=null)
        {
            var myMsg=res.value;
            if(myMsg!=null)
            {
                if(myMsg=="Y")
                {
                     alert('Đã duyệt thành công');
                } 
                else if(myMsg=="N")
                {
                     alert('Hủy bỏ thành công');
                }               
            }          
           
        }
        else
        {
            alert('Error !!!')
        }
        
    }
    
    //Neu co tham so cho in Trang

    try{
            var IsPrint='<%=Request["IsPrint"]%>';
           var CodeID='<%=Request["CodeID"]%>';
          var sOrderID='<%=Request["sOrderID"]%>';  
            var hPrint=document.getElementById("<%= hPrint.ClientID %>")
            if(IsPrint=="Y" && hPrint.value=="0") 
            {
                 fnPrintOrder(CodeID,sOrderID,"Y");
                 hPrint.value="1";
            }  
    }
    catch(e){}
    
    function fnPrintOrder(CodeID,OrderID,State)
    {
        var width=screen.availWidth-30;
        var height=screen.availHeight-20;
        var left = parseInt((screen.availWidth/2) - (width/2));
		var top = parseInt((screen.availHeight/2) - (height/2));
        var feature="width="+width+",height="+height+",menu=0,scrollbars=1,status=1,location=0,resizable=1,left=" + left + ",top=20,screenX=" + left + ",screenY=" + top;
        window.open("OrderDetailOK.aspx?CodeID=" + CodeID  + "&sOrderID=" +OrderID+ "&sState=" + State,"",feature)
    }
    </script>

</asp:Content>
